package com.android.jingweiapp.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.android.jingweiapp.util.Contacts;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by cuiwenrui-pc on 15/10/31.
 */
public class NewsBean implements Parcelable {

    public static final Parcelable.Creator<NewsBean> CREATOR = new Parcelable.Creator<NewsBean>() {
        public NewsBean createFromParcel(Parcel source) {
            return new NewsBean(source);
        }

        public NewsBean[] newArray(int size) {
            return new NewsBean[size];
        }
    };
    @Expose
    private String id;
    @Expose
    private String title;
    @Expose
    private String time;
    @Expose
    @SerializedName("source")
    private String from;
    @Expose
    private int type;

    public NewsBean(String id, String title, String time, String from, int type) {
        this.id = id;
        this.title = title;
        this.time = time;
        this.from = from;
        this.type = type;
    }

    public NewsBean(JSONObject object) {
        try {
            this.id = object.getString(Contacts.KEY.KEY_ID);
            this.from = object.getString(Contacts.KEY.KEY_FROM);
            this.time = object.getString(Contacts.KEY.KEY_DATE);
            this.title = object.getString(Contacts.KEY.KEY_TITLE);
            this.type = object.getInt(Contacts.KEY.KEY_TYPE);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public NewsBean() {

    }

    protected NewsBean(Parcel in) {
        this.id = in.readString();
        this.title = in.readString();
        this.time = in.readString();
        this.from = in.readString();
        this.type = in.readInt();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.title);
        dest.writeString(this.time);
        dest.writeString(this.from);
        dest.writeInt(this.type);
    }
}
